<?php 

//////////// DATA  ////////////////////////////////
			 $result = query("SELECT menuitems FROM menus WHERE menu_id = '1'");
			 $row_m = mysql_fetch_object($result);
			 $main =  json_c_decode($row_m->menuitems);
			 
			 
			 $result = query("SELECT menuitems FROM menus WHERE menu_id = '2'");
			 $row_m = mysql_fetch_object($result);
			 $second =  json_c_decode($row_m->menuitems);
			 
			 
			 $sql = "SELECT `values`  FROM `setings` WHERE `type` = 'tabs' ";
			 $setings = mysql_fetch_assoc(query($sql));
			 $sections =  json_c_decode($setings['values']);
			 
			 
//////////// MAIN MENU ////////////////////////////////
			 
			 
			 function main_menu($ar)
			 {
					$menu_id = 1;
					echo '<ul>';
					foreach ($ar as $key => $value) {
					
						$item = $value['id'];
						
						$sqlm = "SELECT parent_id,title FROM  menu_description 
							  WHERE menu_id = '".$menu_id."'AND item_id = '".$item."'
							  AND lang_id = '".$_SESSION['lang_id']."'
							 ";
					
						$rowm = mysql_fetch_object(query($sqlm)); 
					
						$sql_sef = "SELECT s.sef_url, p.class FROM  sef_url AS s , pages as p 
							  WHERE s.query = '".$rowm->parent_id."' 
							  AND s.tamplate='page' 
							  AND s.lang_id = '".$_SESSION['lang_id']."'
							  AND s.query = p.page_id
							 ";
						$row_sef = mysql_fetch_object(query($sql_sef));
						
						echo '<li><a href="#'.$row_sef->sef_url.'" class="scroll">'.$rowm->title.'</a></li>';
						
					}
						
				  echo '</ul>';
					
					
			 }
//////////// SECOND MENU ////////////////////////////////
				$js = '';			 
			 function second_menu($ar)
			 {
					$menu_id = 2;
					global $js ;
					echo '<ul>';
					foreach ($ar as $key => $value) {
					
						$item = $value['id'];
						
						$sqlm = "SELECT parent_id,title FROM  menu_description 
							  WHERE menu_id = '".$menu_id."'AND item_id = '".$item."'
							  AND lang_id = '".$_SESSION['lang_id']."'
							 ";
					
						$rowm = mysql_fetch_object(query($sqlm)); 
					
						$sql_sef = "SELECT s.sef_url, p.class , (SELECT pt.sef_url FROM  sef_url AS pt  WHERE
						 pt.query = p.parent_id AND pt.tamplate='page' 
							  AND pt.lang_id = '".$_SESSION['lang_id']."') AS parentsef FROM  sef_url AS s , pages as p 
							  WHERE s.query = '".$rowm->parent_id."' 
							  AND s.tamplate='page' 
							  AND s.lang_id = '".$_SESSION['lang_id']."'
							  AND s.query = p.page_id
							 ";
						$row_sef = mysql_fetch_object(query($sql_sef));
						
						echo '<li><a href="#'.$row_sef->parentsef.'" rel="#'.$row_sef->sef_url.'"><i class="'.$row_sef->class.'"></i>'.$rowm->title.'</a></li>';
						$js .= "
								$('#quick-links a [rel=\"#".$row_sef->sef_url."\"]').click( function() {
									cinsile.log('".$row_sef->sef_url."');
									$('#".$row_sef->parentsef."').easytabs('select', '#".$row_sef->sef_url."');
								});
								";
					}
						
				  echo '</ul>';
				  
				  if($js){
					 $js =   '<script type="text/javascript">
					  $(document).ready(function () { '. $js.'
					   }); 
					   </script>
					 ';
				  }
					
					
			 }
			 
			




?>
 
 <!DOCTYPE html>
<html lang="<?=$_SESSION['lang']?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Zuzutel</title>
    <!--fonts-->
<!--    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">-->
    <link href='http://fonts.googleapis.com/css?family=Spinnaker' rel='stylesheet' type='text/css'>
    <!--vendor css-->
<!--    <link rel="stylesheet" href="./css/font-awesome.min.css">-->
    <link rel="stylesheet" href="<?=HTML_BASE?>css/font-zuzutel.css">
    <link rel="stylesheet" href="<?=HTML_BASE?>lib/slick/slick.css">
    <!--app css-->
    <link rel="stylesheet" href="<?=HTML_BASE?>css/main.css">
    <!--[if IE 9]>
        <link rel="stylesheet" type="text/css" href="css/ie9.css">
    <![endif]-->
    <!--[if lt IE 9]>
        <link rel="stylesheet" type="text/css" href="css/ie8.css">
    <![endif]-->
     <script src="<?=HTML_BASE?>lib/jquery-1.11.1.min.js"></script>
</head>
<body>
 
    <div id="wrapper">
        <div id="border"></div>

        <div id="inner-wrapper">
            <header id="top-header">
                <a href="#home" id="logo-image" class="scroll">
                    <img src="<?=HTML_BASE?>image/logo.png" alt="">
                </a>
                <nav>
                    <?=main_menu($main)?>
                </nav>
            </header> <!--#header-->
            <nav id="fixed-links-left">
                <ul>
                    <li><a id="user-button" title="login"><i class="fa fa-user"></i></a></li>
                    <li><a href="#" onClick="get_page('faq'); return false;" title="faq"><i class="fa fa-question"></i></a></li>
                </ul>
            </nav>
            <nav id="fixed-links-right">
                <ul>
                    <li class="language-bar"><a  href="<?=HTML_BASE?>en">en</a> / <a href="<?=HTML_BASE?>pt">pt</a> / <a href="<?=HTML_BASE?>bg">bg</a></li>
                    <li><a class="scroll" href="#main-footer" title="contacts"><i class="fa fa-envelope-o"></i></a></li>
                </ul>
            </nav> <!--#fixed-links-->
            <section id="home" class="scrollto">
                <article class="cf">
                    <div id="login-form">
                        <div id="login-form-top">
                            <header>
                                <h2>sign in</h2>
                            </header>
                            <form action="">
                                <input type="text" placeholder="Username">
                                <input type="text" placeholder="Password">
                                <a href="" id="login-button">log in</a>
                            </form>
                            <a class="login-helper">Forgot username?</a>
                            <a class="login-helper">Forgot password?</a>
                        </div>
                        <hr />
                        <div id="register">
                            <div>new to zuzutel</div>
                            <a href="" id="register-link"><i class="fa fa-angle-right"></i> register now</a>
                        </div>
                    </div>
                    <div id="slider-home">
                        <div><img src="<?=HTML_BASE?>image/Audio-conference.jpg" alt=""></div>
                        <div><img src="<?=HTML_BASE?>image/FAX.jpg" alt=""></div>
                        <div><img src="<?=HTML_BASE?>image/SMS.jpg" alt=""></div>
                        <div><img src="<?=HTML_BASE?>image/Voice-Calls.jpg" alt=""></div>
                        <div><img src="<?=HTML_BASE?>image/Virtual-Office.jpg" alt=""></div>
                    </div>
                    <div id="secondary-slider-home">
                        <div>
                                <a href="#s-calls-tab"><i class="fa fa-phone"></i><span class="icon-label-slider">audio conference</span></a>
                        </div>
                        <div>
                                <a href="#s-virtual-office-tab"><i class="fa fa-suitcase"></i><span class="icon-label-slider">virtual office</span></a>
                        </div>
                        <div>
                                <a href="#s-virtual-office-tab"><i class="fa fa-microphone"></i><span class="icon-label-slider">voice calls</span></a>
                        </div>
                        <div>
                                <a href="#s-virtual-office-tab"><i class="fa fa-envelope"></i><span class="icon-label-slider">sms</span></a>
                        </div>
                        <div>
                                <a href="#s-fax-tab"><i class="fa fa-print"></i><span class="icon-label-slider">fax</span></a>
                        </div>



                    </div>
                    <div id="additional-info">
<!--                       <a href="#" onclick="get_page('promotions'); return false;"> <div id="promotions"><i class="fa fa-heart-o"></i> Promotions</div></a>-->
                        <a href="#" onclick="get_page('free-destinations'); return false;"><div id="destinations"><i class="fa fa-compass"></i> Free Destinations</div></a>
                        <div id="ip-info">
                            <div>Your IP address is:</div>
                            <div id="id-address"><?=$_SERVER['REMOTE_ADDR']?></div>
                        </div>
                    </div>
                </article>
                <footer id="footer-home">
                   <div id="curve"></div>
                    <nav id="quick-links">
                        <?=second_menu($second)?>
                    </nav>
                </footer>
            </section> <!--#home view-->
            <script src="<?=HTML_BASE?>lib/jquery-1.11.1.min.js"></script>
<!--    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>-->
<!--    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>-->
<!--   <script src="lib/jquery.hashchange.min.js"></script>-->
    <script src="<?=HTML_BASE?>lib/slick/slick.min.js"></script>
    <script src="<?=HTML_BASE?>lib/jquery.easytabs.js"></script>
    <script src="<?=HTML_BASE?>lib/jquery.slimscroll.js"></script>
            <?php
  /////////////////////sections///////////////////////////////          
			
			function callpalns()
			{
				global $plan_table;
				global $plan_dim;
				$sql = 
							 "SELECT 
							 	 p.plan_id,
								 p.plan_data,
								 pd.title,
								 pd.description 
							  FROM 
								 plans as p,
								 plan_description as pd 
							  WHERE 
								 pd.plan_id = p.plan_id
								 AND pd.lang_id = '".$_SESSION['lang_id']."'
								 AND p.published
							  
							 ";
				$result = query($sql);
				$plans = '';
				$position = 'left';
				$i = 0;
				while($row = mysql_fetch_object($result)){
				$plan = unserialize($row->plan_data);
				$i ++;
				$plans .= '<div class="call-plan">
                            <div class="cp-front">
                                <div class="cp-info '.$position.'">
                                    <h4>'.__call_plan.' '.stripslashes($row->title).'</h4>
                                    <p>'.stripslashes($row->description).'</p>
                                    <span class="flip-button">'.__read_more.'</span>
                                </div>
                                <div class="cp-viewport">
                                    <div class="cp-circle">
                                        <h4>'.stripslashes($row->title).'</h4>
                                        <div class="cp-price">'.__from.': <span>€'.$plan['p1m'].'</span></div>
                                    </div>
                                </div>
                            </div>
                            <div class="cp-back">
                                <div>
                                    <div class="cp-left">
									<div class="rotate-text main-line">
                                            <div class="inner-line">'.__call_plan.'</div>
                                            '.stripslashes($row->title).'
                                        </div>
									</div>
                                    <div class="cp-scroll">
                                        <ul>';
										
								foreach($plan as $key=>$value) 
								{ 
									 if($key != 'is_submitted' && $key != 'redirectForm' && $key != 'published'){
										if($key != 'p1m' && $key != 'p3m' && $key != 'p6m' && $key != 'p12m'){
											if($value == '-1')	 $value	 = __Unlimited;
											if($key == 'simultaneous_access' || $key == 'audio_conference' || $key == 'fax' || $key == 'wvacc3' || $key == 'voice_mail' || $key == 'call_back'  )	 $value	 = '<span class="tick-'.$value.'"></span>';
											
										
										$plans .=  '<li>
													<div class="cp-feature"><span>'.$plan_table[$key].'</span></div>
													<div class="cp-feature-description">'.$value.$plan_dim[$key];
												if($key == 'freecalls' )	$plans .= '<br><a href="#"  onClick="get_page(\'plan\',\''.$row->plan_id.'\'); return false;" >'.__read_more.'</a>';
										$plans .=		'</div> 
													</li>';
													
													
											
										}
										
									 }
								} 
                                            
                                            
                                  $plans .= '      </ul>
                                    </div>
                                    <div class="cp-calculator">
                                        <div class="red-heading">'.__CALCULATOR.'</div>
                                        <div>'.__CHOOSE_PERIOD.'</div>
                                        <select onChange="$(this).next().html(\''.__Fee.' \' + $(this).val()+ \'€\');" >
                                            <option value="'.$plan['p1m'].'">1 '.__month.'</option>
                                            <option value="'.$plan['p3m'].'">3 '.__month.'</option>
                                            <option value="'.$plan['p6m'].'">6 '.__month.'</option>
											<option value="'.$plan['p12m'].'">12 '.__month.'</option>
										</select>
                                        <div class="footnote">
                                            '.__Fee.''.$plan['p1m'].'€
                                        </div>
										
										<a href="#"  class="red-button" onClick="get_page(\'plans-info\'); return false;" >'.__more_info.'</a>
                                    </div>
                                    <div class="cp-close-button">x</div>
                                </div>
                            </div>
                        </div> ';
					if($position == 'left'){
						 $position = 'right';
					}else{
						$position = 'left';
					}
				}
				$plans .= '<div  onClick="get_page(\'compare\'); return false;" id="compare-plans-button">'.__COMPARE_PLANS.'</div>';
				return $plans;
			}
			
			function price_list(){

				$alphabet = array('A','B','C','D','E','F','G','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
				$tabs = array("calls","fax","sms","conference");
				$content = '<ul>
                                <li><a href="#pl-calls-tab">calls</a></li>
                                <li><a href="#pl-fax-tab">fax</a></li>
                                <li><a href="#pl-sms-tab">sms</a></li>
                                <li><a href="#pl-conference-tab">voice calls</a></li>
                            </ul>';
				 foreach($tabs as $tab){	 
					
					$content .=	'<div id="pl-'.$tab.'-tab" class="cf inner-tab">
									<div class="table-pl-container cf">
										<div class="filter-alphabet">
											<ul>';
							  foreach($alphabet as $ab){
								  $content .=	' <li><a onClick="get_tarifs(\''.$tab.'\', \''.$ab.'\', $(\'#'.$tab.'trf\')); return false;" href="#">'.$ab.'</a></li>';
							  }
				   
					$content .=	'</ul>
								  </div>
								  <header class="cf">
									  <span class="pl-table-left">Country</span>
									  <span class="pl-table-right">Price , € </span>
								  </header>
								  <ul class="table-pl" id="'.$tab.'trf">
									  
									  
								 </ul>
								 <script>
								  $(document).ready(function() {
                						get_tarifs(\''.$tab.'\', \'a\', $(\'#'.$tab.'trf\'));
           						  });
								 </script>
								 
							  </div>
						  </div>';
					  
				 }
							$content .=	'<div onclick="get_page(\'plans-info\'); return false;" id="compare-plans-button">'.__more_info.'</div>';
							return $content ;
				
			}
			
			
			function sections($ar,$level,$parent)
			 {
				 	$content = '';
					$nav = '';
					
					
					foreach ($ar as $key => $value) {
					
						$sql_all = 
							 "SELECT s.sef_url, 
							 		 p.class,
									 p.parent_id,
									 d.title,
									 d.description 
							  FROM  
							  		 sef_url AS s ,
							   		 pages as p,
									 page_description as d 
							  WHERE 
							  s.query = '".$value['id']."' 
							  AND s.query = p.page_id
							  AND s.tamplate='page' 
							  AND s.lang_id = '".$_SESSION['lang_id']."'
							  AND d.page_id = p.page_id
							  AND d.lang_id = '".$_SESSION['lang_id']."'
							  
							 ";
						$row = mysql_fetch_object(query($sql_all));
						
						if($level == 0){
						echo '<section id="'.$row->sef_url.'" class="cf scrollto">';
               			echo ' <header><h2>'.$row->title.'</h2></header>';
						echo '	<article class="tabs cf" id="'.$row->sef_url.'-tabs">';
						echo stripslashes($row->description);
						
						if($value['children']) sections($value['children'],$level+1,$row->sef_url);
						
						echo '	</article>';
           				echo '</section>'; 
						echo '
						<script>
						$("#'.$row->sef_url.'-tabs").easytabs({
								tabs: $("#'.$row->sef_url.'-tabs .etabs > li")
							});
						</script>
						';
						}
						
						if($level == 1){
							
                            $nav .= '<li class="tab"><a href="#'.$row->sef_url.'"><i class="'.$row->class.'"></i><span class="icon-label">'.$row->title.'</span></a></li>';
							
							$content .= '<div id="'.$row->sef_url.'" class="tab-panel">'; 
							$content .= stripslashes($row->description);
							
							if($value['children']){
								 $content .= '<div id="'.$row->sef_url.'s" class="inner-tabs-container">';
								 $content .= sections($value['children'],$level+1,$row->sef_url);
								 $content .= '</div>';
								 $content .= '<script>
									$("#'.$row->sef_url.'s").easytabs();
									</script>';
							}
							
							if($row->sef_url == 'callplans-tab'){
								 $content .= callpalns();
							}
							
							if($row->sef_url == 'price-list-tab'){
								
								 $content .= '<div id="'.$row->sef_url.'s" class="inner-tabs-container">';
								 $content .= price_list();
								 $content .= '</div>';
								 $content .= '<script>
									$("#'.$row->sef_url.'s").easytabs();
									</script>';
							}
							
							$content .= '</div>';
                     
						}
						
						if($level == 2){
							
                          
						$nav .= '<li class="'.$row->class.'"><a  class="'.$row->class.'" href="#'.$row->sef_url.'">'.$row->title.'</a></li>';
							
							$content .= '<div   id="'.$row->sef_url.'" class="inner-tab '.$row->class.'">'; 
							$content .= stripslashes($row->description);
								
							$content .= '</div>';
                     
						}
						
						
					}
				
				
				if($level == 1){
					echo '<nav> <ul class="etabs cf"> '.$nav.' </ul> </nav>';
					echo $content;
				}
				
				if($level == 2){
					return '<ul> '.$nav.' </ul> '.$content;
					
				}
				
					
			 }
			
			sections($sections,0,'');
			
			
			
			
			
			?>
            
           
            
            
            
 <?php
  ////////////////////////////////////////////////////          
			
			
			?>           
            
            
            
            <script>
			function get_tarifs(cat, key, element){
				  $.ajax({
                    type: 'POST',
                    url:'<?=HTML_BASE?>ajax_price.php',
                    data: {category:cat, index:key},
                    success: function(msg){
                                $(element).html(msg);
                               	
                            },
                    error: function(msg){
                               alert('Error:'+ msg);
                               
                            }
                });
			}
			
			
			function get_page(url,id){
				  $.ajax({
                    type: 'POST',
                    url:'<?=HTML_BASE?>ajax_page.php',
                    data: {page:url, id:id},
                    success: function(msg){
                               
								$('#popup-page section').html(msg);
								$('#popup-page').show();
                               	
                            },
                    error: function(msg){
                               alert('Error:'+ msg);
                               
                            }
                });
			}
			
			
			
			</script>
            
             <footer id="main-footer" class="cf scrollto">
                <div id="main-footer-curve"></div>
                <div class="top cf">
                
                <?php 

				$sqlnew =  "SELECT 
							  s.sef_url,
							  p.new_id,
							  p.creation_time,
							  d.title,
							  d.description
										
						FROM 
							  sef_url AS s,
							  news AS p,
							  news_description AS d
						WHERE 
							 p.new_id = d.new_id
							 AND d.lang_id = '".$_SESSION["lang_id"]."'
							 AND s.lang_id = '".$_SESSION["lang_id"]."'
							 AND s.query =   p.new_id
							 AND s.tamplate = 'new'
							 ORDER BY  p.creation_time DESC LIMIT 1
						 ";
							
				$rnew = mysql_fetch_object(query($sqlnew)); 
				
				
				?>
				
                    <div id="news">
                        <h4>latest news</h4>
                        <h5><?=date('d.M.Y', strtotime($rnew->creation_time))?></h5>
                        <p><?=text_format($rnew->description, 220)?>...</p>
                        <a class="read-more" href="#" onClick="get_page('<?=$rnew->sef_url?>'); return false;">read more...</a>
                    </div>
                    <div id="get-in-touch">
                        <h4>get in touch</h4>
                        <div id="contact-links">
                            <a href=""><i class="fa fa-weixin"></i> online chat</a>
                            <a href="#" onClick="get_page('contacts'); return false;"><i class="fa fa-envelope"></i> contact form</a>
                        </div>
                        <div id="social-links">follow us: 
                            <a href=""><i class="fa fa-facebook-square"></i></a>
                            <a href=""><i class="fa fa-twitter"></i></a>
                            <a href=""><i class="fa fa-linkedin"></i></a>
                            <a href=""><i class="fa fa-google-plus"></i></a>
                        </div>
                    </div>
                </div> <!--#top-->
                <div class="bottom">
                    <div id="payment-links">
                        <img src="./image/payments.png" alt="">
                    </div>
                    <ul id="terms-links">
                        <li><a href="#" onClick="get_page('terms-of-use'); return false;">Terms of Use</a></li>
                        <li><a href="#" onClick="get_page('privacy-policy'); return false;" >Privacy Policy</a></li>
                        <li><a href="#" onClick="get_page('faq'); return false;">FAQ</a></li>
                    </ul>
                </div>
            </footer>
            
            
                 </div> <!--#inner-wrapper-->
        <footer id="bottom-footer">
            <div><span id="copyright">Copyright&copy; Zuzutel 2014</span><span id="design">designed by <a href="">.ADV</a> | developed by <a href="http://studiokipo.com/" target="_blank">KIPO</a></span></div>
        </footer>
        <div id="popup-page">
            <div id="inner-wrapper-popup-page">
                <header>
                    <img src="<?=HTML_BASE?>image/logo.png" alt="">
                    <div class="popup-close-button">x</div>
                    <h2></h2>
                </header>
                <section>
                   
                </section>
            </div>
        </div>
        
        
        <!--remove inline display block style for production style="display: block"-->
        <div id="popup-page">
            <div id="inner-wrapper-popup-page">
                <header>
                    <img src="./image/logo.png" alt="">
                    <div class="popup-close-button">x</div>
                    <h2>Popup info page</h2>
                </header>
                <section>
                <!--start ajax template-->
                <div class="compare-plans cf">
                    <ul class="cp-feature-list cf">
                        <li>SERVICE</li>
                        <li>
                            <div class="cp-feature"><span>Free Calls Countries</span><span></span></div>
                        </li>
                        <li>
                            <div class="cp-feature"><span>Free Calls Countries</span><span></span></div>
                        </li>
                        <li>
                            <div class="cp-feature"><span>Free Calls Countries</span><span></span></div>
                        </li>
                     </ul>
                     <ul class="cp-feature-description-list cf">
                        <li>FREE</li>
                        <li>
                            <div class="cp-feature-description">200 min</div>
                        </li>
                        <li>
                            <div class="cp-feature-description">200 min</div>
                        </li>
                        <li>
                            <div class="cp-feature-description">200 min</div>
                        </li>
                     </ul>
                     <ul class="cp-feature-description-list cf">
                        <li>STARTER</li>
                        <li>
                            <div class="cp-feature-description">300 min</div>
                        </li>
                     </ul>
                     <ul class="cp-feature-description-list cf">
                        <li>ADVANCED</li>                       
                        <li>
                            <div class="cp-feature-description">400 min</div>
                        </li>
                     </ul>
                     <ul class="cp-feature-description-list cf">
                        <li>PROFESSIONAL</li>                        
                        <li>
                            <div class="cp-feature-description">400 min</div>
                        </li>
                     </ul>
                     <ul class="cp-feature-description-list cf">
                        <li>BUSINESS</li>                       
                        <li>
                            <div class="cp-feature-description">500 min</div>
                        </li>
                     </ul>
                </div>
                <!--end ajax template-->
                </section>
            </div>
        </div> <!--#popup-page-->
        
        
    </div> <!--#wrapper-->
    <!--vendor js-->
    <script src="<?=HTML_BASE?>lib/jquery-1.11.1.min.js"></script>
    <script src="<?=HTML_BASE?>lib/slick/slick.min.js"></script>
    <script src="<?=HTML_BASE?>lib/jquery.easytabs.js"></script>
    <script src="<?=HTML_BASE?>lib/boxsizing.htc"></script>
    <script src="<?=HTML_BASE?>lib/modernizr.custom.zuzutel.js"></script>
    <script src="<?=HTML_BASE?>lib/jquery.slimscroll.js"></script>
    <!--app js-->
    <script src="<?=HTML_BASE?>js/main.js"></script>   
    <?=$js?> 
</body>
</html>
